package com.example.test.chapter7.custom_listview_collapsing_row;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

public class PhoneView extends LinearLayout {
	private TextView mPhone;
	private TextView mDetail;

	public PhoneView(Context context, String name, String detail,
			boolean explanded) {
		super(context);
		setOrientation(VERTICAL);
		mPhone = new TextView(context);
		mPhone.setText(name);
		addView(mPhone, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.WRAP_CONTENT));

		mDetail = new TextView(context);
		mDetail.setText(detail);
		addView(mDetail, new LinearLayout.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

		mDetail.setVisibility(explanded ? VISIBLE : GONE);
	}

	public void setName(String name) {
		mPhone.setText(name);
	}

	public void setDetail(String words) {
		mDetail.setText(words);
	}

	public void setExpanded(boolean expanded) {
		mDetail.setVisibility(expanded ? VISIBLE : GONE);
	}
}
